<!DOCTYPE html>
<html lang="en" class="feedback">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>文章详细</title>

		<link rel="stylesheet" href="../../css/simple-line-icons.css">

		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/mui-ext.css">

		<style>
			.head-img {
				width: 36px;
				height: 36px;
				border-radius: 50px;
			}
			
			.head-badge {
				position: absolute;
				top: 60px;
				right: 10px;
				font-size: 8px;
				line-height: 10px;
			}
			
			.head-title {
				font-size: 16px;
			}
			
			.head-desc {
				font-size: 10px;
			}
			
			.head-box {
				text-align: center;
				border-right: 1px solid #eee;
			}
			
			.title-box {
				padding-left: 5px;
			}
			
			.title-icon-box {
				text-align: center;
				padding-left: 5px;
				border-right: 1px solid #eee;
			}
			
			.title-icon-box-last {
				text-align: center;
				padding-left: 5px;
			}
			
			.title-desc {
				padding-top: 10px;
			}
			
			body {
				padding: 0;
				font-family:"微软雅黑";
				background: #fff;
			}
			
			.title {
				display: block;
				font-size: 2em;
				-webkit-margin-before: 0.67em;
				-webkit-margin-after: 0.67em;
				-webkit-margin-start: 0px;
				-webkit-margin-end: 0px;
				font-weight: bold;
				text-align: center;
			}
			
			.activity-info {
				border-top: 1px dotted #ccc;
				text-align: center;
			}
			
			.activity-meta {
				display: inline-block;
				line-height: 16px;
				vertical-align: middle;
				text-align: center;
				margin-left: 8px;
				padding-top: 2px;
				padding-bottom: 2px;
				color: #8c8c8c;
				font-size: 11px;
			}
			
			.content {
				width: 95%;
				margin: 0 auto;
				padding: 5px 5px;
			}
			
			.w-header {
				background-color: #00a8c6;
			}
			
			.bg-base {
				background-color: #00a8c6;
				color: #FFFFFF;
				font-size: 12px;
				filter: alpha(Opacity=80);
				-moz-opacity: 0.8;
				opacity: 0.8;
			}
			
			.bg-color-base {
				background-color: #00a8c6;
			}
			
			.btns-likes {
				position: absolute;
				left: 10px;
				top: 50px;
			}
			
			.btn-float {}
			
			.article-image {
				background-size: contain;
				background-repeat: no-repeat;
				min-height: 200px;
			}
			
			.flex-container {
				display: -webkit-box;
				display: -webkit-flex;
				display: flex;
				-webkit-flex-flow: row wrap;
				text-align: center;
			}
			
			.icon-cycle {
				margin: 3px;
				width: 40px;
				height: 40px;
				display: inline-block;
				text-align: center;
				background-color: #fff;
				border: 1px solid #ddd;
				border-radius: 25px;
				background-clip: padding-box;
			}
			
			.mui-content-padded a .mui-icon {
				margin-top: 0px;
			}
			
			.title-section {
				padding: 0px 15px 0px 15px;
			}
			
			.label-row {
				padding: 5px;
			}
			
			.artile-body {
				padding-left: 5px;
				padding-right: 5px;
			}
			
			.artile-body .content img {
				max-width: 100%;
				height: auto;
			}
			
			.artile-content-body {
				color: #000000;
			}
			
			.artile-comment {
				min-height: 50px;
			}
			
			.artile-footer {
				height: 60px;
			}
			
			.comment-row {
				padding-top: 5px;
			}
			
			.comment-content {
				font-weight: 700;
				padding-top: 15px;
			}
			
			.comment-author {
				font-weight: 600;
				color: #8F8F94;
				padding-right: 10px;
			}
			
			.comment-role {
				font-weight: 400;
				font-size: 12px;
				color: #8F8F94;
			}
			
			.comment-date {
				font-weight: 400;
				font-size: 12px;
				color: #8F8F94;
			}
			
			.icon-num-right {
				float: right;
			}
			
			.icon-liked {
				color: red;
			}
		</style>
	</head>

	<body>
		<!--<header class="mui-bar mui-bar-nav" style="background: #00a8c6;color: #FFFFFF;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: #FFFFFF;"></a>
			<h1 class="mui-title" style="color: #FFFFFF;">文章详情</h1>
		</header>-->
		<div class="mui-content" style="background-color: white;">
			<div class="mui-card">
				<div class="mui-card-header">
					<div class="title-desc">
						<!--
                        	作者：xuzhao_deng@sina.com
                        	时间：2016-12-12
                        	描述：文章标题
                        -->
						<span style="color: #909090; font-size: 17px;" id="dv-art-title"></span>
					</div>
				</div>
				<div class="mui-card-content" style="padding: 0px 0px;">

					<div class="title-section" style="padding-bottom: 0px;border-bottom: 1px dotted #ccc;">
						<div class="mui-row">
							<!--<div class="mui-col-xs-2">
								<div class="icon-cycle">
									<img class="mui-media-object head-img" id="head-img" src="" width="32">
								</div>
							</div>-->
							<!--<div class="mui-col-xs-4">
								<div class="mui-media-body" style="line-height: 40px;">
									<h5 class="mui-badge mui-badge-warning">专家</h5>
									<span class="mui-icon-sm " style="padding-left:10px;">90天前</span>
								</div>
							</div>-->
							<div class="mui-col-xs-2">

							</div>
							<div class="mui-col-xs-4 icon-num-right">
								<!--<div class="mui-row">
									<div class="mui-col-xs-4 icon-speech mui-icon-sm" id="comment-btn" style="line-height: 40px;">
										<span class="btn-float" id="comment-count">0</span>
									</div>
									<div class="mui-col-xs-4 icon-like mui-icon-sm " id="like-btn" style="line-height: 40px;">
										<span class="btn-float" id="like-count">0</span>
									</div>
									<div class="mui-col-xs-4 mui-icon-sm icon-star " id="favorite-btn" style="line-height: 40px;">
										<span class="btn-float" id="favorite-count">0</span>
									</div>
								</div>-->
							</div>
							<div class="mui-col-xs-0 icon-num-right">
							</div>
							<div class="mui-col-xs-0 icon-num-right">
							</div>
						</div>
					</div>

					<div class="artile-body" id="artile-body">
						<!--
                        	作者：xuzhao_deng@sina.com
                        	时间：2016-12-12
                        	描述：文章详细
                        -->
						
					</div>
				</div>

				<div class="mui-card-footer">
				</div>
			</div>

			<!--
				作者：xuzhao_deng@sina.com
				时间：2016-12-12
				描述：评论列表
			-->
			<div class="mui-card" id="commentHeader">
				<div class="mui-card-content" style="padding: 10px 0px;">

					<div class="artile-comment title-section" id="dv-commentLst">
						<!--<div style="display: flex; width: 100%; margin: 5px 0px 15px 0px;">
							<div style="float: left; width: 20%;">
								<img src="../../img/icon/zhuanjia.png" height="40" width="40" style="-moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius:15px;" />
							</div>
							<div style="width: 60%;">
								<span style="font-size: 16px; color: #303030;">苏小妹</span>
								<span style="display: block; font-size: 15px; color: #909090; margin: 20px 0px 0px 0px;">啦啦啦啦啦了</span>
							</div>
							<div style="float: right; width: 20%; margin: auto 0px auto 0px;">
								<span style="font-size: 15px; color: #909090;">2天前</span>
							</div>
						</div>
						<hr />-->
						<!--<div style="display: flex; width: 100%; margin: 5px 0px 15px 0px;">
							<div style="float: left; width: 20%;">
								<img src="../../img/icon/zhuanjia.png" height="40" width="40" style="-moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius:15px;" />
							</div>
							<div style="width: 60%;">
								<span style="font-size: 16px; color: #303030;">苏小妹</span>
								<span style="display: block; font-size: 15px; color: #909090; margin: 20px 0px 0px 0px;">啦啦啦啦啦了</span>
							</div>
							<div style="float: right; width: 20%; margin: auto 0px auto 0px;">
								<span style="font-size: 15px; color: #909090;">2天前</span>
							</div>
						</div>
						<hr />
						<div style="display: flex; width: 100%; margin: 5px 0px 15px 0px;">
							<div style="float: left; width: 20%;">
								<img src="../../img/icon/zhuanjia.png" height="40" width="40" style="-moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius:15px;" />
							</div>
							<div style="width: 60%;">
								<span style="font-size: 16px; color: #303030;">苏小妹</span>
								<span style="display: block; font-size: 15px; color: #909090; margin: 20px 0px 0px 0px;">啦啦啦啦啦了</span>
							</div>
							<div style="float: right; width: 20%; margin: auto 0px auto 0px;">
								<span style="font-size: 15px; color: #909090;">2天前</span>
							</div>
						</div>-->

					</div>
					<div style="height: 30px;">

					</div>
				</div>
			</div>
		</div>
		<nav class="mui-bar mui-bar-tab">
			<form class="mui-input-group" style="padding: 5px;">

				<div class="mui-row">
					<div class="mui-col-xs-10">
						<input type="text" placeholder="说说..." id="txt-comment">
					</div>
					<div class="mui-col-xs-2">
						<button id="btn-addComment" type="button" class="mui-btn mui-btn-default" style="min-width:40px;top:2px;" onclick="return false;">评论</button>
					</div>
				</div>

			</form>
		</nav>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/utils/http.utils.js"></script>
		<script src="../../js/bus/pubfun.js"></script>
		<script type="text/javascript">
			mui.init();
			//var $artHref = window.location.href;
			//var $art_href = $artHref.split("?artid=");
			var $art_id = getQueryString(window.location.search, "artid");
			//$art_href[1];
			window.onload = function(){
				if(fun_loadArticleDail()){
					fun_loadCommLst();
				}
			}
			
			function fun_commentLstHtml($comm, $num){
				var $nickName = "";
				if($comm.commentUser.nickName == null || $comm.commentUser.nickName == ""){
					$nickName = "无名氏";
				} else {
					$nickName = $comm.commentUser.nickName;
				}
				//../../img/icon/zhuanjia.png
				var $commHtml = 
				'<div style="display: flex; width: 100%; margin: 5px 0px 15px 0px;">'
				+	'<div style="float: left; width: 20%;">'
				+		'<img src="' + $comm.commentUser.faceImage + '" height="40" width="40" style="-moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius:15px;" />'
				+	'</div>'
				+	'<div style="width: 50%;">'
				+		'<span style="font-size: 16px; color: #303030;">'+ $nickName +'</span>'
				+		'<span style="display: block; font-size: 15px; color: #909090; margin: 20px 0px 0px 0px;">'+ $comm.content +'</span>'
				+	'</div>'
				+	'<div style="float: right; width: 30%; margin: auto 0px auto 0px;">'
				+		'<span style="font-size: 13px; color: #909090;">'+ $comm.commentTimeDiff +'</span>'
				+	'</div>'
				+'</div>'
				+'<hr />';
				return $commHtml;
			}
			
			function fun_loadCommLst(){
				mui.ajax({
					url : $request_url.getCommentLst,
					type : "get",
					dataType : "json",
					headers: {
					"Authorization": $headers_authorization
					},
					data : {
						objectType : "article",
						destObjectId : $art_id,
						rows : 10,
						page : 0
					},
					success : function(dat){
						if(dat.code == 0){
							var $artCommLst = document.getElementById("dv-commentLst");
							var $commArr = dat.result;
							if($commArr != null && $commArr != ""){
								for(var i = 0; i < $commArr.length; i ++){
									var $commDoc = document.createElement("div");
									$commDoc.innerHTML = fun_commentLstHtml($commArr[i], i);
									$artCommLst.appendChild($commDoc);
								}
							}
						} else {
							mui.toast(dat.message);
						}
						
					}, error : function(err){
						mui.toast("无评论数据...");
					}
				});
			}
			
			function fun_loadArticleDail(){
				mui.ajax({
					url : $request_url.getArticleByInfo,
					type : "get",
					dataType : "json",
					headers: {
					"Authorization": $headers_authorization
					},
					data : {
						id : $art_id,
					},
					success : function(dat){
						if(dat.code == 0){
							var $art_desc = dat.result;
							console.log(dat);
							document.getElementById("dv-art-title").innerHTML = dat.result.title;
							var $artContent = document.getElementById("artile-body");
							var $artDiv = document.createElement('div');
							$artDiv.innerHTML = dat.result.content;
							$artContent.appendChild($artDiv);
							return true;
						} else {
							mui.alert(dat.message);
							return false;
						}
					}, error : function(err){
						mui.toast("无数据源...")
						return false;
					} 
				});
				return true;
			}
			
			var $currUser = JSON.parse(localStorage.getItem("login-user-parent"));
			//评论
			document.getElementById("btn-addComment").addEventListener("tap", function(){
				if($currUser == null || $currUser == ""){
					mui.toast("尚未登录，无法评论")
					return;
				}
				var $comment = document.getElementById("txt-comment").value;
				if($comment == null || $comment == ""){
					mui.toast("请写入评论内容");
					return;
				}
				
				mui.ajax({
					url : $request_url.addComment,
					type : "post",
					dataType : "json",
					headers: {
						"Authorization": $headers_authorization
					},
					data : { 
						userId : $currUser.userId,
						objectType : "article",
						destObjectId : $art_id,
						commentContent : $comment
					},
					success : function(dat){
						if(dat.code == 0){
							var $commHtmls = document.getElementById("dv-commentLst");
							var $dvComm = document.createElement("div");
							$dvComm.innerHTML = fun_commentHtml(dat.result);
							$commHtmls.appendChild($dvComm);
							document.getElementById("txt-comment").value = "";
						} else {
							mui.toast(dat.message);
							return;
						}
					}, error : function(err){
						mui.toast("服务繁忙...");
						return;
					}
				});
				
			});
			
			function fun_commentHtml($comm){
				var $nickName = "";
				if($comm.commentUser.nickName == null || $comm.commentUser.nickName == ""){
					$nickName = "无名氏";
				} else {
					$nickName = $comm.commentUser.nickName;
				}
				//../../img/icon/zhuanjia.png
				var $commHtml = 
				'<div style="display: flex; width: 100%; margin: 5px 0px 15px 0px;">'
				+	'<div style="float: left; width: 20%;">'
				+		'<img src="' + $comm.commentUser.faceImage + '" height="40" width="40" style="-moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius:15px;" />'
				+	'</div>'
				+	'<div style="width: 60%;">'
				+		'<span style="font-size: 16px; color: #303030;">'+ $nickName +'</span>'
				+		'<span style="display: block; font-size: 15px; color: #909090; margin: 20px 0px 0px 0px;">'+ $comm.content +'</span>'
				+	'</div>'
				+	'<div style="float: right; width: 20%; margin: auto 0px auto 0px;">'
				+		'<span style="font-size: 15px; color: #909090;">'+ $comm.commentTimeDiff +'</span>'
				+	'</div>'
				+'</div>'
				+'<hr />';
				return $commHtml;
			}
		</script>
	</body>

</html>